//
// Created by Administrator on 2023/8/1.
//
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int unequalTriplets(vector<int> &nums) {
        int res = 0, n = nums.size();
        sort(nums.begin(), nums.end());
        for (int i = 0, j = 0; i < n; i = j) {
            while (j < n && nums[j] == nums[i]) {
                j++;
            }
            // i 到 j 之间都是相同的
            res += i * (j - i) * (n - j);
        }
        return res;
    }
};

int main() {
    Solution s;
    vector<int> nums = {4, 4, 2, 4, 3};
    cout << s.unequalTriplets(nums) << endl;
    return 0;
}